/*
	动态规划:
		if str1[m] == str2[n]
			L[m, n] = L[m-1, n-1];
		if str1[m] != str2[n]
			L[m, n] = max{L[m, n-1], L[m-1, n]}
*/

#include <iostream>
#include <string>
#include <cstdlib>
#include <cstring>

using namespace std;

const int MAXM = 100;
const int MAXN = 100;
// MAXM rows, MAXN cols
int matrix[MAXM][MAXN]; 
//int ** matrix = (int **)malloc(sizeof(int)*MAXM*MAXN);
int maxString[MAXN];

int maxone(int a, int b) {
	return a > b ? a : b;
}

//int LCSLength(string str1, string str2, int matrix[][MAXN]) {
int LCSLength(string str1, int str1len, string str2, int str2len) {
	for(int i=1; i<=str1len; i++) {
		for(int j=1; j<=str2len; j++) {
			if(str1[i-1] == str2[j-1]) {
				matrix[i][j] = matrix[i-1][j-1] + 1;
			} else {
				matrix[i][j] = maxone(matrix[i][j-1], matrix[i-1][j-1]);
			}
		}
	}

	for(int i=1; i<=str1len; i++) {
		for(int j=1; j<=str2len; j++) {
			cout << matrix[i][j] << " ";
		}
		cout << endl;
	}

	return matrix[str1len][str2len];
}

int main(int argc, char * argv[]) {

	string str1, str2;

	while(cin >> str1 >> str2) {
		memset(matrix, 0, sizeof(matrix));
		memset(maxString, 0, sizeof(maxString));

		int len = LCSLength(str1, str1.length(), str2, str2.length());

		cout << len << endl;
	}
	
	return 0;
}
